from pynput import keyboard,mouse
from global_values import gg
def on_click(x,y, button, pressed): 
    gg.status = 0
    if not gg.not_show_always:
        gg.not_show_one_time =False

def on_move(x,y):
    print(x,y)
    if not gg.not_show_one_time:
        gg.status = 1
    gg.x = x
    gg.y = y
    gg.set_showL(y)

import time
last_p = ''
last_shift_time = 0
def on_release(key):    
    global last_shift_time
    x = str(key)
    print('r',x)
    if 'shift_r' in x and x==last_p:
        if time.time()-last_shift_time<0.3:
            gg.not_show_always = not gg.not_show_always
            return
        gg.not_show_one_time = not gg.not_show_one_time
        if gg.not_show_one_time:  
            gg.status = 0
        else:
            gg.status = 1
        last_shift_time = time.time()
def on_press(key):    
    global last_p
    x = str(key)
    print(x)  
    last_p = x
listener = keyboard.Listener(
    on_press=on_press,
    on_release=on_release
)   
listener.start()
def testa():    
    mouse_listener = mouse.Listener(on_click=on_click,on_move=on_move)
    mouse_listener.start()
    mouse_listener.join()